<% address_id = address_type.chars.first %>
<div class="inner" data-hook=<%="#{address_type}_inner" %>>
  <p class="field" id=<%="#{address_id}firstname" %>>
    <%= form.label :firstname, Spree.t(:first_name) %><span class="required">*</span><br />
    <%= form.text_field :firstname, :class => 'required' %>
  </p>
  <p class="field" id=<%="#{address_id}lastname" %>>
    <%= form.label :lastname, Spree.t(:last_name) %><span class="required">*</span><br />
    <%= form.text_field :lastname %>
  </p>
  <% if Spree::Config[:company] %>
    <p class="field" id=<%="#{address_id}company" %>>
      <%= form.label :company, Spree.t(:company) %><br />
      <%= form.text_field :company %>
    </p>
  <% end %>
  <p class="field" id=<%="#{address_id}address1" %>>
    <%= form.label :address1, Spree.t(:street_address) %><span class="required">*</span><br />
    <%= form.text_field :address1, :class => 'required' %>
  </p>
  <p class="field" id=<%="#{address_id}address2" %>>
    <%= form.label :address2, Spree.t(:street_address_2) %><br />
    <%= form.text_field :address2 %>
  </p>
  <p class="field" id=<%="#{address_id}city" %>>
    <%= form.label :city, Spree.t(:city) %><span class="required">*</span><br />
    <%= form.text_field :city, :class => 'required' %>
  </p>
  <p class="field" id=<%="#{address_id}country" %>>
    <%= form.label :country_id, Spree.t(:country) %><span class="required">*</span><br />
    <span id=<%="#{address_id}country-selection" %>>
      <%= form.collection_select :country_id, available_countries, :id, :name, {}, {:class => 'required'} %>
    </span>
  </p>

  <% if Spree::Config[:address_requires_state] %>
    <p class="field" id=<%="#{address_id}state" %>>
      <% have_states = !address.country.states.empty? %>
      <%= form.label :state, Spree.t(:state) %><span class='required' id=<%="#{address_id}state-required"%>>*</span><br/>

      <span class="js-address-fields" style="display: none;">
        <%=
          form.collection_select(
            :state_id, address.country.states, :id, :name,
            {:include_blank => true},
            {
              class: have_states ? 'required' : '',
              style: have_states ? '' : 'display: none;',
              disabled: !have_states
            })
          %>
        <%=
          form.text_field(
            :state_name,
            class: !have_states ? 'required' : '',
            style: have_states ? 'display: none;' : '',
            disabled: have_states
          )
        %>
      </span>
      <noscript>
        <%= form.text_field :state_name, :class => 'required' %>
      </noscript>
    </p>
  <% end %>

  <p class="field" id=<%="#{address_id}zipcode" %>>
    <%= form.label :zipcode, Spree.t(:zip) %><% if address.require_zipcode? %><span class="required">*</span><% end %><br />
    <%= form.text_field :zipcode, :class => "#{'required' if address.require_zipcode?}" %>
  </p>
  <p class="field" id=<%="#{address_id}phone" %>>
    <%= form.label :phone, Spree.t(:phone) %><% if address.require_phone? %><span class="required">*</span><% end %><br />
    <%= form.phone_field :phone, :class => "#{'required' if address.require_phone?}" %>
  </p>
  <% if Spree::Config[:alternative_shipping_phone] %>
    <p class="field" id=<%="#{address_id}altphone" %>>
      <%= form.label :alternative_phone, Spree.t(:alternative_phone) %><br />
      <%= form.phone_field :alternative_phone %>
    </p>
  <% end %>
</div>
